package com.tvunetworks.center.device.controller;

import com.github.pagehelper.PageInfo;
import com.tvunetworks.center.common.model.LoginUser;
import com.tvunetworks.center.common.model.vo.UserDeviceRecordVo;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.center.common.util.ResultUtil;
import com.tvunetworks.center.device.annotation.Logined;
import com.tvunetworks.center.device.model.param.UserDeviceRecordParam;
import com.tvunetworks.center.device.service.UserDeviceRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * @program: tvucc-aggregator
 * @author lebronchen
 * @create: 2019-08-01 15:26
 **/
@Slf4j
@RestController
@RequestMapping("/userDeviceOperation")
public class UserDeviceRecordController {
    @Autowired
    private UserDeviceRecordService deviceOperationService;

    /**
     * 分页查询设备
     * @param loginUser loginUser
     * @param extendExternalParam extendExternalParam
     * @return Result
     */
    @RequestMapping("/list")
    public Result list(@Logined LoginUser loginUser, UserDeviceRecordParam extendExternalParam){

        if (loginUser == null) {
            return ResultUtil.noLogin();
        }
        PageInfo<UserDeviceRecordVo> pageInfo = null;
        try {
            pageInfo = deviceOperationService.list(extendExternalParam);
        } catch (Exception e) {
            log.error("deviceOperationService.list Exception:[{}]",e);
            pageInfo = new PageInfo<>();
        }

        return ResultUtil.success(pageInfo);
    }
}
